var districtSearch = new AMap.DistrictSearch({
    // 关键字对应的行政区级别，country表示国家
    level: 'country',
    //  显示下级行政区级数，1表示返回下一级行政区
    subdistrict: 3,
    showbiz:false
})
var districtJson = {};
districtJson.attributes = {parentCode:null}
districtJson.id = "100000"
districtJson.name = '全国'
districtSearch.search('中国',function (status,res){
    createSubCity(res.districtList[0],districtJson)

    //下拉树 所属区域
    $("#spiderArea").dropDownForZ({
        // url:'fixed',
        data: [districtJson],
        width:'99%',
        height:'350px',
        selecedSuccess:function(data){  //选中回调
            $("#spiderArea").val(data.name);
        }
    });
});

function createSubCity(res,districtJson){
    if(res.districtList){
        districtJson.children =[]
        for(var i in res.districtList){
            districtJson.children[i]={
                attributes:{parentCode: res.adcode},
                name:res.districtList[i].name,
                id:res.districtList[i].adcode
            }
            createSubCity(res.districtList[i],districtJson.children[i])
        }
    }else{
        return
    }
}